function Share_Data(data,tableid) {
	var buffer = new StringBuffer();
	$(data).each(function(i,info){
		try{
		info.Context=decodeURI(info.Context);
		}catch(e){}
		buffer.append('<div class="sharelist border-bottom" tableid="'+tableid+'" id="'+info.ID+'" userid="'+info.UserID+'" username="'+info.RealName+'">');
		buffer.append('<div class="atitle">');
		buffer.append('<div class="aimg"><img src="'+info.HeadImg+'"/></div>');
		buffer.append('<div class="aname">'+info.RealName+'</div>');
		buffer.append('<div class="adate">'+info.CreateTime+'  &nbsp;&nbsp;&nbsp;&nbsp; 来自&nbsp;'+info.Version+'</div>');
		buffer.append('<div class="atag">分享</div>');
		buffer.append('</div>');
		buffer.append('<div class="asendrange">发送给：<font>'+info.ToUsers+'</font></div>');
		
		buffer.append('<div class="aimg">');
		$(info.Imgs).each(function(k,img)
		{
		var right=k%3==2?0:5;
		buffer.append('<figure class="asquare" style="width:'+(swidth-30)/3+'px; heigth:'+(swidth-30)/3+'px; margin-right:'+right+'px; float:left; display:block;" itemscope itemtype="http://schema.org/ImageObject"><a src="'+img.Img1000+'" itemprop="contentUrl" data-size="'+img.Width+'x'+img.Height+'"><img src="' + img.Img200 + '" width="'+(swidth-30)/3+'" height="'+(swidth-30)/3+'" itemprop="thumbnail" alt="Image description"/></a></figure>');
		});
		buffer.append('</div>');
		if(info.Files.length>0)
		{
		buffer.append('<div class="afile">');
		$.each(info.Files,function(k,info)
		{
					buffer.append('<div class="file_list">');
						buffer.append('<div class="file_icon"><img src="img/'+GetICON(info.Path)+'"/></div>');
						buffer.append('<div class="file_info">');
							buffer.append('<div class="file_name">' + info.Name + '</div>');
							buffer.append('<div class="file_size">' + GetSize(info.Size) + '</div>');  
						buffer.append('</div>'); 
						buffer.append('<div class="file_download"><a href="javascript:void(0)" onclick=DownLoad(this,"'+info.Path+'")></a></div>');
					buffer.append('</div>');
		});
		buffer.append('</div>');
		}
		buffer.append('<div class="acontent"><span>' + info.Context + '</span><div id="detail">'+info.Context.DHtmlButImg().Cut()+'</div></div>');
		if(info.HasVote)
		{
		buffer.append('<div class="votelist">');
		buffer.append('<div class="vtitle">'+info.Vote.Title+'</div>');
		buffer.append('<div class="maxselect">最多选择'+info.Vote.MaxSelect+'项<br><font>该投票为：'+(info.Vote.Anonymous?"匿名投票，请放心大胆的投吧":"非匿名投票")+'</font></div>');
		buffer.append('<div class="vtips">提示：'+info.Vote.Count+'人已投票，截止时间：'+info.Vote.EndTime+'</div>'); 
		if(info.Vote.VotePower)
		{
		buffer.append('<div class="options">');
		$.each(info.VoteOption,function(k,option){
		buffer.append('<div class="line"><div class="check"><input id="option'+i+""+k+'" value="' + (k + 1) + '-' + option.ID + '" type="checkbox" onclick="CheckNum(this,' + info.Vote.MaxSelect + ')"/></div><div class="option"><label for="option'+i+""+k+'">'+(k+1)+'、'+option.Title+'</label></div></div>'); 
		});
		buffer.append('</div>');
		buffer.append('<div class="submitvote">');
		buffer.append('<button class="button middle green" onclick=Throw_Vote(this,"' + info.Vote.ID + '")>投票</button>');
		buffer.append('</div>');
		}
		if(info.Vote.SeeUser.indexOf(","+userid+",")>-1)
		{
			buffer.append(Init_Vote(info.VoteOption,info.Vote.Anonymous));
		}
		buffer.append('</div>');
		}
		
		if(info.Address!=""){
		buffer.append('<div class="aposition"><div class="icon"><img src="img/position2.png" height="22"/></div><div class="address">'+info.Address+'</div></div>');
		}
		buffer.append('<div class="atool">');
		if(info.UserID==userid){
		buffer.append('<div class="delete"><img src="img/delete.png" height="12"/></div>');
		}
		buffer.append('<div class="reply" text="回复"><img src="img/replyes.png" height="12"/></div></div>');
		if(info.ReplyList.length>0)
		{
			buffer.append('<div class="replylist">');
			$(info.ReplyList).each(function(i,reply){
				try{
				reply.Context=decodeURI(reply.Context);
				}catch(e){}
				if(reply.ParentID==0)
				{
					buffer.append('<div class="replyline" id="'+reply.ID+'" userid="'+reply.UserID+'" tableid="'+tableid+'" username="'+reply.UserName+'" sid="'+info.ID+'" parentid="'+reply.ParentID+'"><font>'+reply.UserName+'：</font>'+reply.Context+'</div>');
				}else{
					buffer.append('<div class="replyline" id="'+reply.ID+'" userid="'+reply.UserID+'" tableid="'+tableid+'" username="'+reply.UserName+'" sid="'+info.ID+'" parentid="'+reply.ParentID+'"><font>'+reply.UserName+'</font>回复<font>'+reply.ToUserName+'：</font>'+reply.Context+'</div>');
				}
			});
			buffer.append('</div>');
		}
		buffer.append('</div>');
	});
	return buffer.toString();
};

function Init_Share(){
	get("divmsgname").addEventListener("tap",function(){
		OpenOAScreen(Share_Search_Code(),function(){
			Init_Share_Search();
		},function(){Data_Search(1)});
	});
	
};

function Share_Search_Code(){
	var buffer = new StringBuffer();
	buffer.append('<div class="searchtab"><div class="tab select" val="out">我发出的</div><div class="tab" val="in">我收到的</div></div>');
	buffer.append('<div class="searchline" style="margin-top:10px;"><div class="names">选择同事</div><div class="option"><input id="users_search" class="users" show="1" touserid="" todepartid="" tocomid="" type="text" placeholder="点击选择" readonly="readonly" value=""/></div></div>');
	buffer.append('<div class="searchline"><div class="names">发布时间</div><div class="option"><input id="begindate_search" type="text" class="date" placeholder="开始时间" readonly="readonly"/><input id="enddate_search" type="text" class="date" placeholder="结束时间" readonly="readonly"/></div></div>');
	return buffer.toString();
};

function Init_Share_Search(){
	mui(".searchtab").on("tap",".tab",function(){
		if($(this).attr("val")=="out")
		{
			$(this).css("border-right","1px solid #e3e2e2").siblings().css("border-left","0px");
		}else
		{
			$(this).css("border-left","1px solid #e3e2e2").siblings().css("border-right","0px");
		}
		$(this).addClass("select").siblings().removeClass("select");
		Data_Search(1);
	});
	mui(".option").on("tap",".date",function(){
		obj=this;
			var t=new Date();
			if($(this).val()!="")
			{
				var year_month_day=$(this).val().split("-");
				t.setFullYear(year_month_day[0]);
				t.setMonth(year_month_day[1]-1);
				t.setDate(year_month_day[2]);
			}
			plus.nativeUI.pickDate( function(e){
				var d=e.date;
				$(obj).val((d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()).ToDate());
			},function(e){
				console.log( "未选择日期："+e.message );
			},{date:t});
	});
	get("users_search").addEventListener("tap",function(){
        	obj10=$(this);
			OpenWindow(3,"选择员工","确定",function(){
					var str1="",str2="",str3="",headimg="";
					touserid="";todepartid="";tocomid="";
	      			var count=0;
	      			mui.each(mui("#userlist input"),function(i,info){
	      				if(info.checked)
	      				{
	      					count++;
	      					touserid += info.value+",";
	      					str1 += info.getAttribute("val")+",";
	      				}
	      			});
	      			if(touserid.TrimEnd(",").split(",").length>1)
					{
						plus.nativeUI.toast("请选择1个员工");
						return;
					}
					if(str1=="")
	      			{
	      				obj10.val("").attr("touserid","");
	      			}else
	      			{
	      				
	      				obj10.val(str1.substring(0,str1.length-1)).attr("touserid",touserid.substring(0,touserid.length-1));
	      			}
	      			CloseWindow();
			});
			
			$("#contentlist3").html(CheckMate_Data());
			data = {};
			data.act = "DepartAndUser_Data";
			data.userid=userid;
			data.comid=comid;
			data.source=source;
			data.sign=GetSign(data.act);
			
			mui.getJSON(admin_domain, data, function(json) {
				Bind_CheckMate(json.data.user,json.data.depart);
				Init_CheckMate();
			});
			if($(this).attr("show")=="1")
	      	{
	      		$(".selectbar").hide();
	      	}else
	      	{
				$(".selectbar").show();  				
	      	}
	    });

};

function Animate_Vote() {
    var vs = $(".voteline");
    for (var i = 0; i < vs.length; i++) {
        var obj = $($($(vs[i]).find("div")[1]));
        var str = obj.attr("title").split("-");
        var percent = parseFloat(str[0]) / parseFloat(str[1]);
        obj.animate({ width: percent * 100 + "%" });
    }
};

function Throw_Vote(o, vid) {
    
    var checknum = $(o).parent().parent().find("input:checked").length;
    var data = {};
    if (checknum == 0) {
        plus.nativeUI.alert("请选择投票项");
        return;
    }
    else {
        var ck = $(o).parent().parent().find("input:checked");
        data.voteoption = "";
        for (var n = 0; n < ck.length; n++) {
            data.voteoption += ck[n].value.split("-")[1] + ",";
        }
    }
    o.disabled = "disabled";
    data.act = "Add_VoteUser";
    data.vid = vid;
    data.userid=userid;
	data.comid=comid;
	data.source=source;
	data.sign=GetSign(data.act);
    mui.getJSON(index_domain, data, function (json) {
        if (json.state) {
            try {
                var vs = $(o).parent().parent().find(".voteline");
                var checkbox = $(o).parent().parent().find(":input");
                var allnum = parseInt($($($(vs[0]).find("div")[1])).attr("title").split("-")[1]) + checknum;
                for (var i = 0; i < vs.length; i++) {
                    var obj = $($($(vs[i]).find("div")[1])); //标有数据的对象
                    var titles = obj.attr("title").split("-");
                    if (checkbox[i].value.split("-")[0] == (i + 1 + "") && checkbox[i].checked) {
                        var currentnum = parseInt(titles[0]) + 1;
                        obj.attr("title", currentnum + "-" + allnum);
                        obj.parent().parent().next().find("a").html(currentnum + "人");
                        obj.parent().parent().next().next().html("(" + Math.round(parseFloat(currentnum + "") / allnum * 100) + "%)");
                    }
                    else {
                        var currentnum = parseInt(titles[0]);
                        obj.attr("title", currentnum + "-" + allnum);
                        obj.parent().parent().next().find("a").html(currentnum + "人");
                        obj.parent().parent().next().next().html("(" + Math.round(parseFloat(currentnum + "") / allnum * 100) + "%)");
                    }
                }
            } catch (e) {
            }
            Animate_Vote();
            plus.nativeUI.toast(json.msg); 
        } else {
            //LayerBox.Msg.Error(json.msg);
        }
        o.disabled = "disabled";
        $(o).css("background", "#d1d1d1").css("border", "1px solid #c9c8c8").css("cursor", "not-allowed");
    });
};


//初始化投票
function Init_Vote(data, anonymous) {
    var buffer = new StringBuffer();
    var color = new Array("#498904", "#ef3a4b", "#e705ba", "#6a05e7", "#07bfbd", "#02a411", "#915d02", "#583ed7", "#0380ea", "#555554", "#04c595", "#d90486", "#015362");
    buffer.append("<table style='line-height:24px;table-layout:auto; margin-top:10px;'>");
    var sum = 0;
    for (var i = 0; i < data.length; i++) {
        sum += data[i].Count;
    }
    for (var i = 0; i < data.length; i++) {
        if (sum != 0)
            percent = Math.round(parseFloat(data[i].Count + "") / sum * 100); 
        else
            percent = 0;
        buffer.append("<tr class='voteline'>");
        buffer.append("<td style='line-height:12px; width:60%; float:left;'><p style='font-size:12px;'>" + data[i].Title + "</p></td>");
        buffer.append("<td style='line-height:12px;width:20%;float:left;'><div style='width:100%; height:12px; background-color:#e9ebeb;'><div title='" + data[i].Count + "-" + sum + "' style='width:0px; height:12px;background:" + color[i] + ";'></div></div></td>");
        buffer.append("<td style='line-height:12px;padding:0 4px;width:12%;float:left;'><a onmouseover=Load_VoteUser('" + data[i].ID + "'," + anonymous + ",this)>" + data[i].Count + "人</a></td>");
        buffer.append("<td style='line-height:12px;width:8%;float:left; text-align:right'>" + percent + "%</td>");
        buffer.append("</tr>");
    }
    buffer.append("</table>");
    return buffer.toString();
};

function CheckNum(o, maxnum) {
    var vote = $(o).parent().parent().parent();
    if (vote.find("input:checked").length > maxnum) {
        o.checked = false;
        plus.nativeUI.alert("您最多可选择" + maxnum + "项");
    } 
};